package eu.webhib.webblog.domain.base;

import eu.webhib.webblog.domain.base.intf.CommonParentChildEntity;
import java.util.*;
import javax.persistence.*;

/**
 * Application common base type of entities with parent/child relationship
 * @param <T> type of the parent/child related entity itself
 */
@MappedSuperclass()
@Access(AccessType.FIELD)
public abstract class CommonParentChildEntityImpl<T extends CommonParentChildEntity<T>>
        extends CommonBaseEntityImpl implements CommonParentChildEntity<T> {

   @Transient
   private List<T> children = new ArrayList<T>(30);

   @Override
   public abstract T getParent();

   @Override
   public abstract void setParent(T parent);

   @Override
   public List<T> getChildren() {
      return children;
   }

   @Override
   public void clearChildren() {
      children = new ArrayList<T>();
   }
}
